<?php

class TourModule extends CWebModule
{
	public static $info = array(
		'name'=>'Tour',
		'description'=>'The tour module manages all tour operations',
		'version'=>'1.0'
	);
	public static function install(){
		self::schema();
		self::priviledge();
	}
	public static function uninstall(){
		if(Yii::app()->db->schema->getTable('tour')){
			Yii::app()->db->createCommand()->dropTable('tour');
		}
	}
	private static function schema(){
		$columns = array(
			'id'=> 'INT(11) PRIMARY KEY',
			'name'=> 'VARCHAR(255)',
		);
		if(!Yii::app()->db->schema->getTable('tour')){
			Yii::app()->db->createCommand()->createTable('tour',$columns);
		}else{
		
		}
	}
	private static function block(){
		
	}
	private static function priviledge(){
		$auth=Yii::app()->authManager;
 
		$auth->createOperation('createTour','create a tour');
		$auth->createOperation('readTour','read a tour');
		$auth->createOperation('updateTour','update a tour');
		$auth->createOperation('deleteTour','delete a tour');
	}
	public function init()
	{
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		$this->setImport(array(
			'tour.models.*',
			'tour.components.*',
		));
	}

	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
}
